/**
 * Model
 *
 * new Model();
 * ------------------------------------
 *
 * API:
 * ------------------------------------
 * init(datas)
 * getProcess()
 * getCaseLog()
 * getCaseItemLog()
 */
(function(global){

    'use strict';

    const logger = WorkflowUtil.newLogger("WorkflowApp/Model");

    let Model = function () {

        this.process = null;//new global.BPMProcess();
        this.caseLog = null;//new global.BPMCaseLog();
        this.caseItemLog = null;//new global.BPMCaseItemLog();

        // TODO 缺少流程图校验信息
    };

    /**
     * 初始化数据模型
     * @param datas
     *
     * datas = {
     *   processXml : "",
     *   processXml : "",
     *   caseWorkitemLogXml : ""
     * }
     */
    Model.prototype.parseProcessFromXML = function(datas){

        //logger.debug("初始化Model, processXml = " + datas.processXml);
        logger.debug("初始化Model");

        //初始化流程
        if(datas.processXml){
            this.process = new global.BPMProcess();
            this.process.fromXML(datas.processXml);
        }
        
        //case 信息
        if(datas.caseLogXml){
            this.caseLog = new global.BPMCaseLog();
            this.caseLog.fromXML(datas.caseLogXml);
        }
        
        if(datas.caseWorkitemLogXml){
            
            this.caseItemLog = new global.BPMCaseItemLog();
            this.caseItemLog.fromXML(datas.caseWorkitemLogXml);
        }
    };

    
    Model.prototype.getProcess = function(){
      return this.process;
    };
    
    Model.prototype.getCaseLog = function(){
        return this.caseLog;
    };
    
    Model.prototype.getCaseItemLog = function(){
        return this.caseItemLog;
    };

    global.Model = Model;

})(WorkflowApp);
